<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
class UserController extends Controller{
	
	private $UserModel;
	
	public function __init(){
		$this->UserModel=M('\Common\Model\sc_user');
		
	}
	
	//登录
	public function login(){
		
		if(IS_AJAX){
			if(!$this->UserModel->checkLogin()){
				
				$this->ajax(['status'=>false,'message'=>$this->UserModel->getError()]);
			}
			    $this->ajax(['status'=>true,'message'=>'登录成功！']);
			
		}
		
		
		
		View::make();
		
		
		
		
	}
	
	
	
	//注册
	public function reg(){
		
		if(IS_AJAX){
			if(!$this->UserModel->store()){
				$this->ajax(['status'=>false,'message'=>$this->UserModel->getError()]);
			}else{
				$this->ajax(['status'=>true,'message'=>'注册成功']);
				
			}
		}
		
		View::make();
	}
	
	
	//退出
	public function out(){
		unset($_SESSION['info']);
		
		go('Index/index');
	}
	
	
	
	
	
	
	
	
	
	public function code(){
		Code::height(40)->make();
	}
	
	
	
	
	
}
